﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data {
	public partial class ChargeMap
		: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Charge> {
		public ChargeMap() {
			// table
			ToTable("mc_Charge", "dbo");

			// keys
			HasKey(t => t.Id);

			// Properties
			Property(t => t.Id)
				.HasColumnName("Id")
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
				.IsRequired();
			Property(t => t.OrderNo)
				.HasColumnName("OrderNo")
				.HasMaxLength(50)
				.IsRequired();
			Property(t => t.MerchantId)
				.HasColumnName("MerchantId")
				.IsRequired();
			Property(t => t.BindId)
				.HasColumnName("BindId")
				.IsRequired();
			Property(t => t.OrderTime)
				.HasColumnName("OrderTime")
				.IsRequired();
			Property(t => t.Status)
				.HasColumnName("Status")
				.IsRequired();
			Property(t => t.PayId)
				.HasColumnName("PayId")
				.IsOptional();
			Property(t => t.OrderAmount)
				.HasColumnName("OrderAmount")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.SubsidyAmount)
				.HasColumnName("SubsidyAmount")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.PayAmount)
				.HasColumnName("PayAmount")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.Fee)
				.HasColumnName("Fee")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.FeeAmount)
				.HasColumnName("FeeAmount")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.Amount)
				.HasColumnName("Amount")
				.HasPrecision(18, 6)
				.IsRequired();
			Property(t => t.MerchantFee)
				.HasColumnName("MerchantFee")
				.HasPrecision(18, 4)
				.IsRequired();
			Property(t => t.MerchantSettle)
				.HasColumnName("MerchantSettle")
				.HasPrecision(18, 2)
				.IsRequired();
			Property(t => t.PlatFee)
				.HasColumnName("PlatFee")
				.HasPrecision(18, 5)
				.IsRequired();
			Property(t => t.PlatSettle)
				.HasColumnName("PlatSettle")
				.HasPrecision(18, 2)
				.IsRequired();

			// Relationships
			HasRequired(t => t.Merchant)
				.WithMany()
				.HasForeignKey(d => d.MerchantId)
				.WillCascadeOnDelete(false);
			HasRequired(t => t.Binder)
				.WithMany()
				.HasForeignKey(d => d.BindId)
				.WillCascadeOnDelete(false);
			HasOptional(t => t.PayInfo)
				.WithMany()
				.HasForeignKey(d => d.PayId)
				.WillCascadeOnDelete(false);
		}
	}
}
